package com.koron.operation.classes.info.service.impl;


import com.koron.operation.classes.info.bean.po.ClassesItem;
import com.koron.operation.classes.info.mapper.ClassesItemMapper;
import com.koron.operation.classes.info.service.ClassesItemService;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 班别列表(ClassesItem)表服务实现类
 *
 * @author jzp
 * @since 2021-10-19 19:10:13
 */
@Service
public class ClassesItemServiceImpl implements ClassesItemService {

    /**
     * 通过ID查询单条数据
     */
    @Override
    @TaskAnnotation("getById")
    public ClassesItem getById(SessionFactory factory, String id) {
        ClassesItemMapper mapper = factory.getMapper(ClassesItemMapper.class);
        return mapper.selectById(id);
    }

    /**
     * 查询所有数据
     */
    @Override
    @TaskAnnotation("list")
    public List<ClassesItem> list(SessionFactory factory, ClassesItem classesItem) {
        ClassesItemMapper mapper = factory.getMapper(ClassesItemMapper.class);
        return mapper.selectList(classesItem);
    }

    /**
     * 新增数据
     */
    @Override
    @TaskAnnotation("save")
    public boolean save(SessionFactory factory, ClassesItem classesItem) {
        ClassesItemMapper mapper = factory.getMapper(ClassesItemMapper.class);
        return mapper.insert(classesItem) > 0;
    }

    @Override
    @TaskAnnotation("saveBatch")
    public boolean saveBatch(SessionFactory factory, List<ClassesItem> classesItems) {
        ClassesItemMapper mapper = factory.getMapper(ClassesItemMapper.class);
        return mapper.insertBatch(classesItems) > 0;
    }

    /**
     * 修改数据
     */
    @Override
    @TaskAnnotation("update")
    public boolean update(SessionFactory factory, ClassesItem classesItem) {
        ClassesItemMapper mapper = factory.getMapper(ClassesItemMapper.class);
        return mapper.update(classesItem) > 0;
    }

    /**
     * 通过主键删除数据
     */
    @Override
    @TaskAnnotation("deleteById")
    public boolean deleteById(SessionFactory factory, String id) {
        ClassesItemMapper mapper = factory.getMapper(ClassesItemMapper.class);
        return mapper.deleteById(id) > 0;
    }
}
